<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <button id="btn">点击查询数据</button>
</body>
<script>
  window.onload = function() {
    var btn = document.getElementById('btn');
    btn.onclick = function() {
      // 1.实例化ajax对象
      var xhr = new XMLHttpRequest;
      // 2.配置请求信息，建立连接
      var url = 'http://47.94.46.113:7788/category/findAll';
      var token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VySWQiOiJNUT09Iiwic3ViIjoiYWRtaW4xIiwiaXNzIjoiMDk4ZjZiY2Q0NjIxZDM3M2NhZGU0ZTgzMjYyN2I0ZjYiLCJpYXQiOjE2MjEyMzUyNDksImF1ZCI6InJlc3RhcGl1c2VyIiwiZXhwIjoxNjIxNDA4MDQ5LCJuYmYiOjE2MjEyMzUyNDl9.hmHuQK-Sy7pTvmcDC1fiqYuVl3tK1M2bfl7FANRfqwM';
      xhr.open('GET',url);
      xhr.setRequestHeader('Authorization',token);
      // 3.发送请求
      xhr.send();
      // 4.接受响应信息
      xhr.onreadystatechange = function() {
        if(xhr.readyState == 4 && xhr.status == 200){
          console.log(JSON.parse(xhr.response));
        }
        // console.log(xhr);
      }
    }
  }
</script>
</html>